package com.gxa.controller;

import com.gxa.common.R;
import com.gxa.common.ResponseData;
import com.gxa.pojo.Activity;
import com.gxa.pojo.Dept;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Controller
@Api(value = "活动数据test",tags = "活动数据接口API")
@RequestMapping(value = "/activity",method = RequestMethod.GET)
public class ActivityController {
//    @Autowired
//    private ActivityService activityService;
    @RequestMapping(value = "/queryActivity",method = RequestMethod.GET)
    @ApiOperation(value = "活动查询接口",notes = "传递当前页码数和每页显示记录数",httpMethod = "GET",response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    @ResponseBody
    public ResponseData queryActivity(@RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize){
        ResponseData rd = new ResponseData();
        rd.setCode(200);
        rd.setMsg("success");
        List<Activity> activityList = new ArrayList<>();
        Activity activity01 = new Activity();
        activity01.setActivity_theme("123");
        activity01.setActivity_time("2021-12-2");
        activity01.setActivity_content("111111");
        Activity activity02 = new Activity();
        activity02.setActivity_theme("456");
        activity02.setActivity_time("2021-12-2");
        activity02.setActivity_content("22222");
        activityList.add(activity01);
        activityList.add(activity02);
        rd.setData(activityList);
        return rd;
//        return activityService.queryActivity(currentPage,pageSize);
    }
      // 添加
      @RequestMapping(value = "/addActivity",method = RequestMethod.POST)
      @ApiOperation(value = "添加活动接口",notes = "活动信息",httpMethod = "POST", response = ResponseData.class)
      @ApiResponses({
              @ApiResponse(code=200,message="请求成功"),
              @ApiResponse(code=404,message="找不到页面"),
              @ApiResponse(code=500,message="后台服务错误")
      })
      @ResponseBody
      public ResponseData addActivity(@RequestBody @ApiParam(name = "activity",value = "活动信息",required = true) Activity activity){
          ResponseData rd = new ResponseData();
          rd.setCode(200);
          rd.setMsg("success");
          rd.setData(activity);
          return rd;
      }
     // 编辑
     @RequestMapping(value = "/updateActivity",method = RequestMethod.POST)
     @ApiOperation(value = "编辑活动接口",notes = "编辑活动信息",httpMethod = "POST", response = ResponseData.class)
     @ApiResponses({
             @ApiResponse(code=200,message="请求成功"),
             @ApiResponse(code=404,message="找不到页面"),
             @ApiResponse(code=500,message="后台服务错误")
     })
     @ResponseBody
     public ResponseData updateActivity(@RequestBody @ApiParam(name = "activity",value = "活动信息",required = true) Activity activity){
         ResponseData rd = new ResponseData();
         rd.setCode(200);
         rd.setMsg("success");
         rd.setData(activity);
         return rd;
     }
     // 删除
     @RequestMapping(value = "/delActivity",method = RequestMethod.POST)
     @ApiOperation(value = "删除活动接口",notes = "删除活动信息",httpMethod = "POST", response = ResponseData.class)
     @ApiResponses({
             @ApiResponse(code=200,message="请求成功"),
             @ApiResponse(code=404,message="找不到页面"),
             @ApiResponse(code=500,message="后台服务错误")
     })
     @ResponseBody
     public ResponseData delActivity(@RequestBody @ApiParam(name = "activity_Id",value = "活动信息",required = true) Integer activity_Id){
         ResponseData rd = new ResponseData();
         rd.setCode(200);
         rd.setMsg("success");
         return rd;
     }
    //关键字查找
    @RequestMapping(value = "/searchActivityList",method = RequestMethod.GET)
    @ApiOperation(value = "活动关键字查找接口",notes = "传递当前页码数和每页显示记录数",httpMethod = "GET",response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })
    @ResponseBody
    public ResponseData searchActivityList(@RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize,@RequestParam("keyword")String keyword){
        ResponseData rd = new ResponseData();
        rd.setCode(200);
        rd.setMsg("success");
        List<Activity> activityList = new ArrayList<>();
        Activity activity01 = new Activity();
        activity01.setActivity_theme("团建");
        activity01.setActivity_time("2021-12-03");
        activity01.setActivity_content("12月3号大家聚餐！！");
        Activity activity02 = new Activity();
        activity02.setActivity_theme("冬游");
        activity02.setActivity_time("2021-12-05");
        activity02.setActivity_content("12月5号冬游！！");
        activityList.add(activity01);
        activityList.add(activity02);
        rd.setData(activityList);
        return rd;
    }

}
